package com.company.Thread;

import javax.sound.midi.Soundbank;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @ProjectName: 复习java
 * @Package: com.company.Thread
 * @ClassName: Callable
 * @Author: wym
 * @Date: 2020/10/13 9:47
 * @Version: 1.0
 */
public class Callable implements Runnable {
    @Override
    public void run() {

    }
}

class MyThread2 implements java.util.concurrent.Callable<Integer>{

    @Override
    public Integer call() throws Exception {
        return 1024;
    }
}

/**
 * 测试线程
 */
class CallableDemo{
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> futureTask = new FutureTask<Integer>(new MyThread2());

        Thread t1=new Thread(futureTask,"aa");

         t1.start();

         int result01=100;
         int  result02=futureTask.get();
        System.out.println((result01+result02));

    }
}

